<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->

<div class="row">
    <div class="col-lg-12">
        <h3 class="page-header">Gửi câu hỏi</h3>
    </div>
    <!-- /.col-lg-12 -->
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-body">
                 <div class="row">
                    <div class="col-lg-9">                       
                    <!--<div class="col-lg-12">--> 
                       <div class="form-group"></div> 
                        <div class="col-lg-12"> 
                            <div class="row">
                                <div class="form-group">
                                    <!--<button type="reset" class="btn btn-default" id ="answer">Trả lời câu hỏi</button>-->
                                    <a class="" href="<?php echo $this->url(array("action"=>"address")) ?>"> <button type="reset" class="btn btn-default" id ="answer">Xem thông báo</button></a>
                                    <!--<input class="btn btn-default   " onclick="return $('#myModal').modal('show')" value="Thêm địa chỉ">-->
                                </div>   
                            </div>                            
                            <div class="row">
                            <div class="form-group" id="form_addquestion">
                                <form role="form" method="POST" name="addtFeedback" onsubmit="return checkinput();" action="<?php //echo $this->url(array("action"=>"listanswer")) ?>">
                                    <div class="col-lg-12">
                                    <div class="form-group">
                                        <div class="row">
                                        <div class="col-lg-2">
                                                <label>Địa chỉ:</label>
                                            </div>
                                            <div class="col-lg-10">
                                                <input type ="hidden"  name="id" id="id" value="<?php echo $this->list_id?>" >
                                                        <input class="btn btn-default" onclick="return $('#myModal').modal('show')" value="Thêm địa chỉ">                                                                                                                                                          
                                                        <textarea type="text" class="form-control" id="list_email" readonly="true"></textarea>
                                            </div>  
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="row">
                                            <div class="col-lg-2">
                                                <label>Tiêu đề:</label>
                                            </div>
                                            <div class="col-lg-10">
                                                <input class="form-control" type ="text"  name="title"  id="title" value="" onKeyUp="limitText(this.form.title,this.form.countdown,100);">
                                            </div>  
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="row">
                                            <div class="col-lg-3">
                                                <label>Nội dung </label>
                                            </div>
                                            <div class="col-lg-12">
                                                <textarea class="ckeditor" name="question_kd" id="question_kd"></textarea>                                   
                                            </div>
                                        </div>                                      
                                    </div>                                        
                                    <div class="form-group"><center>
                                        <button type="submit" class="btn btn-default"id="submit">Gửi</button>
                                        <button type="reset" class="btn btn-default" id="reset">Đặt lại</button></center>
                                    </div>
                                        </div>
                                </form>
                            </div>
                            </div> 
                            <!--</div>--> 
                    </div>
                            <div class="form-group">
                            </div>      
                            <!-- --> 
                            <style>
/*                                #accordion section, #accordion .pointer, #accordion h1, #accordion p {
                                  -webkit-transition: all 0.5s ease-in-out;
                                  -moz-transition: all 0.5s ease-in-out;
                                  -ms-transition: all 0.5s ease-in-out;
                                  transition: all 0.5s ease-in-out;
                                }*/
                                #accordion {
                                  margin-bottom:30px;
                                }
                                #accordion h1 {
                                  line-height:1.2;
                                  font-size:20px;
                                  background-color:#ffffff;
                                  margin:0;
                                  padding: 10px 10px 10px 30px;
                                }
                                
                                #accordion h1 a {
                                  color:black;
                                }
                                #accordion section {
                                  overflow:hidden;
                                  height:220px;
                                  border:1px #333 solid;
                                }
                                #accordion p {
                                  padding:0 10px;
                                  color:black;
                                 
                                  
                                }
                                #accordion section.ac_hidden p:not(.pointer) {
                                  color:#fff;
                                }

                                #accordion section.ac_hidden {
                                  height:auto;
                                }
                                #accordion .pointer {
                                  padding:0;
                                  margin:10px 0 0 6px;
                                  line-height:20px;
                                  width:13px;
                                  position:absolute;
                                }
                                #accordion section:not(.ac_hidden) h1 {
                                  background-color:#c6e1ec;//mau khi ta click chuot
                                }

                                #accordion section:not(.ac_hidden) .pointer {
                                  display:block;
                                  -webkit-transform:rotate(90deg);
                                  -moz-transform:rotate(90deg);
                                  -o-transform:rotate(90deg);
                                  transform:rotate(90deg);
                                  padding:0;
                                  height: auto;
                                  width: auto;
                                }
                                </style>
                                <script>
                                $(document).ready(function() {
                                
                                    $("#accordion section h1").click(function(e) {
                                    $(this).parents().siblings("section").addClass("ac_hidden");
                                    $(this).parents("section").removeClass("ac_hidden");
                                   e.preventDefault();
                                  });
                                });
//                                </script>
                              <!-- --> 
                                   <?php
//                                    echo "<div id=\"accordion\">";
//                                   foreach($this->data as $item)
//                                   {
//                                      
//                                       echo" <section id=\"item1\">
//                                              <p class=\"pointer\">&#9654;</p><h1>".$item['question']."</h1>
//                                              <p>".$item['answer']."</p>
//                                            </section>";
//                                   }
//                                   echo " </div>";
                                   ?>
                                 
                                   <?php 
                                        // echo $this->paginationControl($this->data, 'Sliding' , 'feedback/pagination.phtml'); 
                                   ?>
                            <!-- -->  
                              
                               
                        <!--</div>--> 
                         </div>
                      <div class="col-lg-3"> 
                             <div class="form-group">
                                 <h4><b>THÔNG TIN KHUYẾN MÃI</b></h4>
                            </div>  
                            <div class="form-group">                                
                            
                            <ul class="chat">
                            <?php
                    foreach ($this->items1 as $item) {
                        
                            if ($item->getEvent() == 1) {
                            ?>
                            <li class="left clearfix">
                                <span class="chat-img pull-left">
                                    <img src="<?php echo $this->ImageUrl() ?>/image/icon-hot.gif" alt="User Avatar" class="img-circle">
                                </span>
                                <div class="chat-body clearfix">
                                    <div class="header">
                                        <strong class="primary-font"><a href="#" id="pop-up" onclick="getNewsDetail('<?php echo $this->baseUrl() ?>/default/news/newsdetail',<?php echo $item->getId() ?>,'title','description','content')"><?php echo $item->getTitle() ?></a>
                                        
                                            </strong>
                                    </div>
                                    <small class="text-muted">
                                            <i class="fa fa-clock-o fa-fw"></i> <?php echo GlobalLib::viewDate($item->getCreated()) ?>
                                        </small>
                                    <p>
                                        <?php echo $item->getDescription() ?>
                                        <i class="pull-right"><i class=" fa fa-long-arrow-right"></i><a href="#" id="pop-up" onclick="getNewsDetail('<?php echo $this->baseUrl() ?>/default/news/newsdetail',<?php echo $item->getId() ?>,'title','description','content')">Đọc thêm</a></i>
                                    </p>
                                    
                                </div>
                            </li>
                    <?php } } ?> 
                                </ul>
                            </div>
                    </div>  
                    </div>
            </div>
        </div>
    </div>   
</div>
<script type="text/javascript">
    function limitText(limitField, limitCount, limitNum) {
            if (limitField.value.length > limitNum) {
                    limitField.value = limitField.value.substring(0, limitNum);
            } else {
                    limitCount.value = limitNum - limitField.value.length;
            }
    }
</script>
<form  id="addAgent" method="POST" onsubmit="if(document.getElementById('AgentorStore').innerHTML == 'Thêm đại lý mới') return checkAgent(2); else return checkAgent(1);">
    <div id="myModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;</button>
                    <h4 class="modal-title">
                        <center>
                            Danh sách người dùng                            
                        </center>
                    </h4>
                </div>
                <div class="modal-body">    
                    
                    <div class="row">
                        <ul class="list-group" style="max-height: 200px; overflow-y: scroll;">
                        <?php 
                         foreach($this->my_list_kinhdoanh as $user)
                         {                             
                             echo "<li class ='list-group-item'>".
                                     "<input type='hidden' id='user_id".$user->getId()."' value='".$user->getUsername()."'/>".
                                     "<input type='hidden' id='name_id".$user->getId()."' value='".$user->getLast_Name()." ".$user->getFirst_Name()."'/>".
                                     "<input class='mycheckbox' type='checkbox'/ id='id".$user->getId()."'> ".
                                     $user->getUsername()." (".$user->getFirst_Name()." ".$user->getLast_Name()." - ".$user->getPhone().")"
                                     ."</li>";
                         }
                        ?>
                        </ul>
                    </div>
                    
                    <div class="col-lg-2">
                        <span style="color: Red;"></span></div>
                </div>                    
                <div class="modal-footer">    
                    <center>
                        <button id="choose_user"  class="btn btn-primary" type="button">
                            Chọn
                        </button>
                        <button type="button" id="close" class="btn btn-default" data-dismiss="modal">
                            Đóng
                        </button>
                    </center>
                </div>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    $("#choose_user").click(function()
    {
        var str="";
        $("#list_email").val("");
        $("input.mycheckbox").each(function(index){            
            if($("input.mycheckbox").eq(index).is(':checked'))
            {
                str = str+ $("input.mycheckbox").eq(index).attr('id'); 
                
                $("#list_email").val($("#list_email").val()+$("#name_"+$("input.mycheckbox").eq(index).attr('id')).val()
                        +"("+$("#user_"+$("input.mycheckbox").eq(index).attr('id')).val()+")"+";");
                str=str.replace("id","");                
                str =str+",";
            }
                        
        });
        str=str.substring(0,str.length -1);
        $("#id").val(str);                  
        $("#myModal").modal('hide');        
    });
</script>
<!---------->
<!-- modal -->
<div id="myModal1" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;</button>
                    <h4 class="modal-title">
                        <center>
                            <strong id="title"></strong>
                        </center>
                    </h4>
                </div>
                <div class="modal-body">    
                    <strong id="description"></strong><br>
                    <p id="content"></p>
                    
                </div>                    
            </div>
        </div>
    </div>
<script type="text/javascript">
  $('#myModal1').modal('hide');
  function getNewsDetail(url,news_id,title_id,description,content_id){
    var params={
      news_id:news_id 
    };
    $.post(url,params,function(datas){
        $('#myModal1').modal('show');         
        var items=datas.split('[]');       
        if(items[0]!=''){         
           $('#title').html(items[0]);
           $('#description').html(items[1]);
           $('#content').html(items[2]);
        }
    });
   
}
</script>
<script type="text/javascript">
    document.forms['addtFeedback'].name.focus();
    function set_focus() {
        document.forms['addtFeedback'].name.focus();
    }
    function checkinput(){
        var frm = window.document.addtFeedback; 
         if (frm.title.value == "") {
            bootbox.alert("Vui lòng nhập tiêu đề cho câu hỏi!");
            return false;
        }
        if(CKEDITOR.instances.question_kd.getData()==""){
            bootbox.alert("Vui lòng nhập nội dung cho câu trả lời");
            return false;
        }       
        return true;
    }
   
</script>
<script type="text/javascript"> 
     $('#reset').click( function (){	
        CKEDITOR.instances.question_kd.setData("");
    }); 
</script>